//
//  Ray.hpp
//  RayTracer
//
//  Created by 俞云康 on 2/15/16.
//  Copyright © 2016 yushroom. All rights reserved.
//

#ifndef Ray_hpp
#define Ray_hpp

#include "Math.hpp"

class Ray {
public:
    float3  o;
    float3  dir;
    mutable float   maxt    = INFINITY;
    int     depth   = 0;
    
    Ray() : o(0, 0, 0), dir(0, 0, 1), maxt(INFINITY) {}
    Ray(const float3& o, const float3& dir) : o(o), dir(Normalize(dir)) {}
	Ray(const Ray &r) : o(r.o), dir(r.dir), depth(r.depth), maxt(r.maxt) {}
    float3 at(float t) const { return o + dir * t; }
    bool valid() const { return o.valid() && dir.valid() && !isnan(maxt); }
};

#endif /* Ray_hpp */
